package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice._.base.Utils;
import com.sooncode.project.focusservice.model.TestLevel;
import com.sooncode.project.focusservice.service.TestLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("testLevel")
public class TestLevelController {
    @Autowired
    TestLevelService service;
    @PostMapping("testLevel")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }
    @PostMapping("copy")
    public boolean copy(@RequestParam int fromAge,@RequestParam int toAge){
        return service.copy(fromAge,toAge);
    }
    @PutMapping("testLevel")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        return service.modify(id,map);
    }
    @DeleteMapping("testLevel")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("testLevels")
    public Page<TestLevel> getPageList(@RequestParam int pageSize, @RequestParam int pageIndex, @RequestParam Map map){
        map.remove("pageSize");
        map.remove("pageIndex");
        Utils.mapValueTrim(map);
        return service.getPageList(pageSize,pageIndex-1,map);
    }
}
